﻿#define  _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
int Add(int a, int b)
{
	return a + b;
}
int Sub(int a, int b)
{
	return a - b;
}
int Mul(int a, int b)
{
	return a * b;
}
int Div(int a, int b)
{
	return a / b;
}

void Calc(int* (pf)(int, int))
{
	int x = 0;
	int y = 0;
	printf("输入操作数：");
	scanf("%d %d", &x, &y);
	int ret = pf(x, y);
	printf("ret = %d\n", ret);
}


int main()
{
	int x = 0;
	int y = 0;
	int input = 1;
	int ret = 0;
	do
	{
		printf("*************************\n");
		printf("  1:Add           2:Sub  \n");
		printf("  3:Mul           4:Div  \n");
		printf("  0:exit                 \n");
		printf("*************************\n");
		printf("请选择：");
		scanf("%d", &input);
		switch (input)
		{
		case 1:
			Calc(Add);
			break;
		case 2:
			Calc(Sub);
			break;
		case 3:
			Calc(Mul);
			break;
		case 4:
			Calc(Div);
			break;
		case 0:
			printf("退出程序\n");
			break;
		default:
			printf("选择错误\n");
			break;
		}
	} while (input);
	return 0;
}